import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:moose_app/core/model/poetry_model.dart';
import 'package:moose_app/core/utils/navigate_util.dart';
import 'package:moose_app/ui/screens/detail/detail_screen.dart';
import 'package:moose_app/ui/values/values.dart';
import 'package:moose_app/ui/widgets/operator_view.dart';

class ATHHomeItem extends StatelessWidget {
  final PoetryItemModel poetryItemModel;

  const ATHHomeItem({this.poetryItemModel, Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Container(
          padding: EdgeInsets.symmetric(vertical: kSize24),
          child: Row(
            children: [
              ClipRRect(
                borderRadius: BorderRadius.all(Radius.circular(kSize60)),
                child: Container(
                  width: kSize120,
                  height: kSize120,
                  alignment: Alignment.center,
                  decoration: BoxDecoration(color: kColorPrimary),
                  child: Text(
                    poetryItemModel.author ?? "",
                    maxLines: 1,
                    textAlign: TextAlign.center,
                    overflow: TextOverflow.ellipsis,
                    style:
                        TextStyle(fontSize: kFontSize32, color: Colors.white),
                  ),
                ),
              ),
              Container(
                padding: EdgeInsets.only(left: kSize24),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      poetryItemModel.author ?? "",
                      maxLines: 1,
                      textAlign: TextAlign.center,
                      overflow: TextOverflow.ellipsis,
                      style: TextStyle(fontSize: kFontSize36, color: kColor33),
                    ),
                    Text(
                      "4 小时前",
                      style: TextStyle(fontSize: kFontSize24, color: kColor33),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
        Container(
          child: Text(
            poetryItemModel.title ?? "",
            maxLines: 1,
            textAlign: TextAlign.center,
            overflow: TextOverflow.ellipsis,
            style: TextStyle(fontSize: kFontSize36, color: kColor33),
          ),
        ),
        Container(
          padding: EdgeInsets.symmetric(vertical: kSize24),
          child: GestureDetector(
              onTap: () {
                ATHNavigator.pushFromRight(context, ATHDetailScreen.routeName);
              },
              child: Text(
                poetryItemModel.body ?? "",
                style: TextStyle(fontSize: kFontSize32, color: kColor33),
              )),
        ),
        ClipRRect(
          borderRadius: BorderRadius.all(Radius.circular(kSize20)),
          child: CachedNetworkImage(
            fit: BoxFit.fill,
            imageUrl:
                'https://moose-plus.oss-cn-shenzhen.aliyuncs.com/2021-01-09/banner-1.png',
            errorWidget: (context, url, error) =>
                Image.asset('assets/images/qrcode_430.jpg', fit: BoxFit.fill),
          ),
        ),
        Container(
            height: kSize100,
            padding: EdgeInsets.only(top: kSize20),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                ATHOperatorView(),
                SvgPicture.asset(
                  "assets/icons/icon_close_r.svg",
                  height: kSize40,
                ),
              ],
            )),
        Divider(),
      ],
    );
  }
}
